<?php

// +----------------------------------------------------------------------
// | author: admin
// +----------------------------------------------------------------------

namespace app\adminapi\lists\travel;


use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\travel\LinePrice;
use app\common\lists\ListsSearchInterface;


/**
 * LinePrice列表
 * Class LinePriceLists
 * @package app\adminapi\liststravel
 */
class LinePriceLists extends BaseAdminDataLists implements ListsSearchInterface
{


    /**
     * @notes 设置搜索条件
     * @return \string[][]
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function setSearch(): array
    {
        return [
            '=' => ['line_id', 'status'],
            'between_time' => 'travel_time',
        ];
    }

    /**
     * @notes 获取列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function lists(): array
    {
        return LinePrice::where($this->searchWhere)
            ->append(['line_name', 'status_value', 'status_remark', 'user_account'])
            ->field(['id', 'line_id', 'price', 'travel_time', 'status', 'user_id'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order(['id' => 'desc'])
            ->select()
            ->toArray();
    }


    /**
     * @notes 获取数量
     * @return int
     * @author admin
     * @date 2025/04/29 09:56
     */
    public function count(): int
    {
        return LinePrice::where($this->searchWhere)->count();
    }

}